//
//  VisitorView.swift
//  weibo
//
//  Created by wang_h on 2017/5/25.
//  Copyright © 2017年 wang_h. All rights reserved.
//

import UIKit

class VisitorView: UIView {
    
    class func visitorView() ->VisitorView {
        return (Bundle.main.loadNibNamed("VisitorView", owner: self, options: nil))?.first as! VisitorView
    }
    @IBOutlet weak var rotationView: UIImageView!
    @IBOutlet weak var iconView: UIImageView!
    @IBOutlet weak var tipLable: UILabel!
    @IBOutlet weak var registerBtn: UIButton!
    @IBOutlet weak var loginBtn: UIButton!
    
    //MARK:- 自定义函数
    func setupVisitorViewInfo(iconName : String, title : String) {
        iconView.image = UIImage(named: iconName)
        tipLable.text = title
        rotationView.isHidden = true
    }
    
    func addRotationAnim() {
        //1.创建动画
        let rotationAnimation = CABasicAnimation(keyPath: "transform.rotation.z") // 让其在z轴旋转
        //2.设置动画的属性
        rotationAnimation.fromValue = 0
        rotationAnimation.toValue = NSNumber(value: Double.pi * 2.0) // 旋转角度
        rotationAnimation.duration = 5 // 旋转周期
        rotationAnimation.repeatCount = MAXFLOAT // 旋转次数
        rotationAnimation.isRemovedOnCompletion = false
        //3.将动画添加到layer中
        rotationView.layer.add(rotationAnimation, forKey: "rotationAnimation")
    }
}
